package com.zhen;

import com.zhen.domain.Clazz;
import com.zhen.factory.FKSqlSessionFactory;
import com.zhen.mapper.ClazzMapper;
import org.apache.ibatis.session.SqlSession;

public class OneToManyTest {

    public static void main(String[] args) {
        SqlSession session = FKSqlSessionFactory.getSqlSession();
        ClazzMapper clazzMapper = session.getMapper(ClazzMapper.class);

        Clazz clazz = clazzMapper.selectById(1);
        System.out.println(clazz.getId() + " " + clazz.getCode() + " " + clazz.getName());
        clazz.getStudents().forEach(student -> System.out.println(student));
        session.commit();
        session.close();
    }

}
